if (inputText.length() > 512) {
    throw new IllegalArgumentException("Input length exceeds maximum allowed length of 512");
}